//
//  GFControl.h
//  MYLC3.0
//
//  Created by 胡林虎 on 16/10/12.
//  Copyright © 2016年 MR.Shang. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface GFControl : NSObject

#pragma mark - For UIView
+ (UIView *)createUIViewWithFrame:(CGRect)frame
                          bgColor:(UIColor *)bgColor;

+ (UIView *)createUIViewWithFrame:(CGRect)frame
                          bgColor:(UIColor *)bgColor
                     cornerRadius:(CGFloat)cornerRadius;

+ (UIView *)createUIViewWithFrame:(CGRect)frame
                          bgColor:(UIColor *)bgColor
                     cornerRadius:(CGFloat)cornerRadius
                    actionGesture:(UIGestureRecognizer *)gesture;

+ (UIView *)createUIViewWithFrame:(CGRect)frame
                          bgColor:(UIColor *)bgColor
                     cornerRadius:(CGFloat)cornerRadius
                        tapAction:(void(^)())tapAction;

#pragma mark - For UILabel
+ (UILabel *)createLabelWithFrame:(CGRect)frame
                             text:(NSString *)text
                    textAlignment:(NSTextAlignment)textAlignment
                         fontSize:(CGFloat)fontSize;

+ (UILabel *)createLabelWithFrame:(CGRect)frame
                             text:(NSString *)text
                    textAlignment:(NSTextAlignment)textAlignment
                         fontSize:(CGFloat)fontSize
                        textColor:(UIColor *)textColor;

+ (UILabel *)createLabelWithFrame:(CGRect)frame
                             text:(NSString *)text
                    textAlignment:(NSTextAlignment)textAlignment
                         fontSize:(CGFloat)fontSize
                        textColor:(UIColor *)textColor
                          bgColor:(UIColor *)bgColor;

+ (UILabel *)createLabelWithFrame:(CGRect)frame
                             text:(NSString *)text
                    textAlignment:(NSTextAlignment)textAlignment
                         fontSize:(CGFloat)fontSize
                        textColor:(UIColor *)textColor
                          bgColor:(UIColor *)bgColor
                     cornerRadius:(CGFloat)cornerRadius;

+ (UILabel *)createLabelWithFrame:(CGRect)frame
                             text:(NSString *)text
                    textAlignment:(NSTextAlignment)textAlignment
                         fontSize:(CGFloat)fontSize
                        textColor:(UIColor *)textColor
                          bgColor:(UIColor *)bgColor
                     cornerRadius:(CGFloat)cornerRadius
                        tapAction:(void(^)())tapAction;

#pragma mark - For UIButton
+ (UIButton *)createButtonWithFrame:(CGRect)frame
                              title:(NSString *)title
                           fontSize:(CGFloat)fontSize
                          imageName:(NSString *)imageName
                        bgImageName:(NSString *)bgImageName
                             action:(void(^)())action;

+ (UIButton *)createButtonWithFrame:(CGRect)frame
                              title:(NSString *)title
                           fontSize:(CGFloat)fontSize
                         titleColor:(UIColor *)titleColor
                            bgColor:(UIColor *)bgColor
                          imageName:(NSString *)imageName
                        bgImageName:(NSString *)bgImageName
                             action:(void(^)())action;

+ (UIButton *)createButtonWithFrame:(CGRect)frame
                              title:(NSString *)title
                           fontSize:(CGFloat)fontSize
                         titleColor:(UIColor *)titleColor
                            bgColor:(UIColor *)bgColor
                          imageName:(NSString *)imageName
                        bgImageName:(NSString *)bgImageName
                       cornerRadius:(CGFloat)cornerRadius
                             action:(void(^)())action;

#pragma mark - For UIImageView
+ (UIImageView *)createImageViewWithFrame:(CGRect)frame
                                imageName:(NSString *)imageName;

+ (UIImageView *)createImageViewWithFrame:(CGRect)frame
                             cornerRadius:(CGFloat)cornerRadius;

+ (UIImageView *)createImageViewWithFrame:(CGRect)frame
                                imageName:(NSString *)imageName
                             cornerRadius:(CGFloat)cornerRadius;

+ (UIImageView *)createImageViewWithFrame:(CGRect)frame
                                imageName:(NSString *)imageName
                             cornerRadius:(CGFloat)cornerRadius
                            actionGesture:(UIGestureRecognizer *)gesture;

+ (UIImageView *)createImageViewWithFrame:(CGRect)frame
                                imageName:(NSString *)imageName
                             cornerRadius:(CGFloat)cornerRadius
                                tapAction:(void(^)())tapAction;

+ (UIImageView *)createImageViewWithFrame:(CGRect)frame
                                imageName:(NSString *)imageName
                              roundCorner:(BOOL)roundCorner
                                tapAction:(void(^)())tapAction;

#pragma mark - For UITextFeild

+ (UITextField *)createTextFiledWithFrame:(CGRect)frame
                              bgImageName:(NSString *)bgImageName
                              placeholder:(NSString *)placeholder;

+ (UITextField *)createTextFiledWithFrame:(CGRect)frame
                              bgImageName:(NSString *)bgImageName
                              placeholder:(NSString *)placeholder
                             cornerRadius:(CGFloat)cornerRadius;

+ (UITextField *)createTextFiledWithFrame:(CGRect)frame
                              bgImageName:(NSString *)bgImageName
                              placeholder:(NSString *)placeholder
                               isPassWord:(BOOL)isPassWord
                             cornerRadius:(CGFloat)cornerRadius;

+ (UITextField *)createTextFiledWithFrame:(CGRect)frame
                              bgImageName:(NSString *)bgImageName
                              placeholder:(NSString *)placeholder
                               isPassWord:(BOOL)isPassWord
                                 leftView:(UIView *)leftView
                                rightView:(UIView *)rightView
                             cornerRadius:(CGFloat)cornerRadius;

// 计算label的size
+ (CGSize)labelAutoCalculateRectWith:(NSString*)text FontSize:(CGFloat)fontSize MaxSize:(CGSize)maxSize;

@end

/**
 *  使用 __unsafe_unretained __typeof(self) weakSelf = self;
 *  防止循环引用
 *
 */
typedef void(^GestureAction)(id gestureRecognizer);

@interface UIGestureRecognizer (Gesture)

-(instancetype)initWithActionBlock:(GestureAction)gestureAction;

- (void)addActionBlock:(GestureAction)block;

@end


